//
//  HLTCustomerserviceTableViewCell.m
//  huiliantong
//
//  Created by hlt on 15/9/6.
//  Copyright (c) 2015年 hlt. All rights reserved.
//

#import "HLTCustomerserviceTableViewCell.h"

@implementation HLTCustomerserviceTableViewCell

- (void)awakeFromNib {
    // Initialization code
    
    
    
    //    指定Delegate
    _pickerview.delegate=self;
    //    显示选中框
    _pickerview.showsSelectionIndicator=YES;
    NSArray *dataArray = [[NSArray alloc]initWithObjects:@"留言",@"投诉",@"询问",@"售后",@"求购",nil];
    
    _pickerData=dataArray;
    
    
    _pickerview.hidden=YES;
    
    
    self.text.delegate=self;
    
    
}


- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        // 初始化时加载collectionCell.xib文件 这个是把这个xib文件全部加载了，然后取第一个
        NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
        
        // 如果路径不存在，return nil
        if (arrayOfViews.count < 1)
        {
            return nil;
        }
        // 如果xib中view不属于UICollectionViewCell类，return nil
        if (![[arrayOfViews objectAtIndex:0] isKindOfClass:[UICollectionViewCell class]])
        {
            return nil;
        }
        // 加载nib
        self = [arrayOfViews objectAtIndex:0];
    }
    return self;
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (IBAction)dianji:(id)sender {
    
    
    
    _pickerview.hidden=NO;
    
    NSInteger row =[_pickerview selectedRowInComponent:0];
    NSString *selected = [_pickerData objectAtIndex:row];
    NSString *message = [[NSString alloc] initWithFormat:@"你选择的是:%@",selected];
    
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
                                                    message:message
                                                   delegate:self
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles: nil];
    [alert show];
    
    
    
}





#pragma mark Picker Date Source Methods

//返回显示的列数
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}
//返回当前列显示的行数
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return [_pickerData count];
}

#pragma mark Picker Delegate Methods

//返回当前行的内容,此处是将数组中数值添加到滚动的那个显示栏上
-(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return [_pickerData objectAtIndex:row];
}




- (void)textFieldDidBeginEditing:(UITextField *)textField{
    //开始编辑时触发，文本字段将成为first responder
    
    
    self.pickerview.hidden=YES;
    
    
}


//按return键时执行的方法
-(IBAction)textFieldDoneEditing:(id)sender
{
    
    self.pickerview.hidden=NO;
    [sender resignFirstResponder];
    
    
    
}







@end
